package com.zxy.ziems.server.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.zxy.ziems.server.utils.tree.TreeInterface;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author bhg
 * @date 2023/3/15
 */
@Data
public class OrgTreeNode implements TreeInterface<OrgTreeNode> {
    /**
     * 组织id
     */
    private String id ;
    /**
     * 组织简称
     */
    private String name ;
    /**
     * 组织编码
     */
    private String code ;

    /**
     * 父节点
     */
    @JsonIgnore
    private String parentId;

    /**
     * 子集
     */
    private List<OrgTreeNode> children = new ArrayList<>();

    public OrgTreeNode(String id, String name, String code, String parentId) {
        this.id = id;
        this.name = name;
        this.code = code;
        this.parentId = parentId;
    }

    @Override
    public String _getTreeCode() {
        return id;
    }

    @Override
    public String _getTreeParentCode() {
        return parentId;
    }

    @Override
    public void _setTreeChildren(List<OrgTreeNode> list) {
        setChildren(list);
    }

    @Override
    public List<OrgTreeNode> _getTreeChildren() {
        return children;
    }
}
